/**
 * Copyright 2010-2025 The mTASK Project Authors. All Rights Reserved.
 * Licensed under the MIT License (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.gitee.com/lort/mTask/LICENSE.md
 * Author: luyunyi @luyunyi2019@outlook.com
 */

#ifndef __MTASKTREE_H__
#define __MTASKTREE_H__

#include <mTaskType.h>
#include <rbtree.h>

#ifdef __cplusplus
extern "C"
{
#endif

struct mTaskNodeStr{
  	struct rb_node node;
  	char    key[mTASK_TREE_KEY_SIZE];
    char    arg[0];
};
struct mTaskNodeInt{
  	struct rb_node node;
  	size_t  key;
    char    arg[0];
};

typedef struct mTaskNodeStr    *mTaskNodeStr_t;
typedef struct mTaskNodeInt    *mTaskNodeInt_t;

mTaskNodeInt_t mTaskTreeeCreateNodeInt(int size);
mTaskNodeInt_t mTaskTreeSearchInt(struct rb_root *root, size_t key);
mTaskNodeInt_t mTaskTreeGetMinNodeInt(struct rb_root *root);
mTaskNodeInt_t mTaskTreeGetMaxNodeInt(struct rb_root *root);
int mTaskTreeInsertInt(struct rb_root *root, mTaskNodeInt_t data);
void mTaskTreeDeleteInt(struct rb_root *root,mTaskNodeInt_t node);

mTaskNodeStr_t mTaskTreeeCreateNodeStr(int size);
mTaskNodeStr_t mTaskTreeSearchStr(struct rb_root *root, char *key);
mTaskNodeStr_t mTaskTreeGetMinNodeStr(struct rb_root *root);
mTaskNodeStr_t mTaskTreeGetMaxNodeStr(struct rb_root *root);
int mTaskTreeInsertStr(struct rb_root *root, mTaskNodeStr_t data);
void mTaskTreeDeleteStr(struct rb_root *root,mTaskNodeStr_t node);



#ifdef __cplusplus
}
#endif


#endif /* MAIN_ELOOP_ELOOP_LOG_H_ */


